Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Designing Applications > Inserting text at the beginning of a NotesRichTextItem
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Community articleInserting text at the beginning of a NotesRichTextItem
Added by ~Hank Nonhipilygon | Edited by ~Hank Nonhipilygon on March 5, 2010 | Version 2
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: NotesRichTextItem RichText LotusScript
ShowTable of Contents
HideTable of Contents
  • 1 About the Author

Some time ago I wrote a small LotusScript agent, that updates a document's NotesRichTextItem with text, that I send to my Notes mailfile. Problem is: I wanted to insert the text at the *beginning* of the Body item, what seems simple and still has some pitfalls. Here is what I tried, and the solution:

 

I started out using the NotesRichTextNavigator and the BeginInsert method. Worked fine - until I had an embedded picture in my item; after the update, the picture showed as a black square (ouch).

 

Next try: Copying the Body item into a temporary NotesRichTextItem, emptying the Body item, writing my text, and then appending the temporary item (appendRTItem). My problem was, that I wanted to leave the temporary item as a backup. In my local tests, this worked perfectly, until I changed the agent settings to "triggered" - which resulted in the error "Notes error: Attachment found on more than one document". The reason obviously is, that after copying the item I had the same attachments in both the Body and the BodyTmp item. Weird, but explainable with a little good-will. What is really surprising is, that this error only occurs in an event triggered agent, not in a manually started agent (did some research after that). The error occurs on the document.save method.

 

Solution: You have to remove the temporary item before saving the document (I used a different way for my backup then).

 

Here is the (shortened) code (removed the dims):

 

Set rtBody = doc.GetFirstItem("Body") ' get the target NotesRichTextItem
Set rtBodyTmp = doc.CopyItem(rt, "Body") ' copy it temporarily
Call rtBody.remove() ' remove the target NotesRichTextItem to "start from scratch"
Set rtBody = New NotesRichTextItem(doc, "Body") ' create a new Body item
Call rtBody.AppendText(myText) ' insert text at top (as the item is empty)
Call rtBody.AppendRTItem(rtBodyTmp) ' now add the former content
Call rtBodyTmp.remove() ' important for triggered (!) agents: remove the temporary item
Call doc.Save(True, False, False)
 

About the Author


Marcus Foerster works as Systems Architect for Pentos AG in Munich, Germany. His focus lies on the application side, creating collaboration systems for users, groups and enterprises to get their daily work done. This approach includes integrating complex workflows with intuitive user interfaces, using Lotus Notes/Domino with Adobe Flex and other Web technologies.
Read more in Marcus' blog: http://marcus.foerster.com/blogexternal link

expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (3)
collapsed Versions (3)
Version Comparison     
VersionDateChanged by              Summary of changes
3Mar 5, 2010, 9:34:44 AM~Frank Quetlupulikle  
This version (2)Mar 5, 2010, 9:33:36 AM~Hank Nonhipilygon  
1Mar 5, 2010, 9:33:10 AM~Hank Nonhipilygon  
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility